﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using roc_control_project;


namespace Axxx_sprial
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            
            InitializeComponent();
            
           
        }

        private void tabPage1_Click(object sender, EventArgs e)
        {

        }

        private void radioButton94_CheckedChanged(object sender, EventArgs e)
        {

        }

       

        private void groupBox6_Enter(object sender, EventArgs e)
        {

        }

        private void groupBox7_Enter(object sender, EventArgs e)
        {
            //Calcu_resistance_value();
        }

        private void groupBox8_Enter(object sender, EventArgs e)
        {
            //Calcu_resistance_value();
        }
        private void groupBox10_Enter(object sender, EventArgs e)
        {
            //Calcu_resistance_value();
        }
        //第4环，误差值
        private void radioButton96_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±1%";
        }

        private void radioButton95_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±2%";
        }

        private void radioButton82_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±0.5%";
        }

        private void radioButton81_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±0.25%";
        }

        private void radioButton80_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±0.1%";
        }

        private void radioButton78_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±5%";
        }

        private void radioButton79_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±10 %"; 
        }
        //第5环，误差值
        private void radioButton49_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±1 %";
        }

        private void radioButton48_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±2 %";
        }

        private void radioButton45_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±0.5 %";
        }

        private void radioButton44_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±0.25 %";
        }

        private void radioButton43_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±0.1 %";
        }

        private void radioButton42_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±5 %";
        }

        private void radioButton41_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Text = "±10 %";
        }
        //四色环阻值计算
        public void Calcu_resistance_value()
        {
           double  A1=0, A2=0, A3=0, sum=0;
            //第一环
            if (radioButton94.Checked == true) A1 = 0;
            else if (radioButton93.Checked == true) A1 = 1;
            else if (radioButton92.Checked == true) A1 = 2;
            else if (radioButton91.Checked == true) A1 = 3;
            else if (radioButton90.Checked == true) A1 = 4;
            else if (radioButton89.Checked == true) A1 = 5;
            else if (radioButton88.Checked == true) A1 = 6;
            else if (radioButton87.Checked == true) A1 = 7;
            else if (radioButton86.Checked == true) A1 = 8;
            else if (radioButton85.Checked == true) A1 = 9;
            //第二环
            if (radioButton67.Checked == true) A2 = 0;
            else if (radioButton66.Checked == true) A2 = 1;
            else if (radioButton65.Checked == true) A2 = 2;
            else if (radioButton64.Checked == true) A2 = 3;
            else if (radioButton63.Checked == true) A2 = 4;
            else if (radioButton62.Checked == true) A2 = 5;
            else if (radioButton61.Checked == true) A2 = 6;
            else if (radioButton60.Checked == true) A2 = 7;
            else if (radioButton59.Checked == true) A2 = 8;
            else if (radioButton58.Checked == true) A2 = 9;
            //第三环
            
            if (radioButton77.Checked == true)      A3 = 1;
            else if (radioButton76.Checked == true) A3 = 10;
            else if (radioButton75.Checked == true) A3 = 100;
            else if (radioButton74.Checked == true) A3 = 1000;
            else if (radioButton73.Checked == true) A3 = 10000;
            else if (radioButton72.Checked == true) A3 = 100000;
            else if (radioButton71.Checked == true) A3 = 1000000;
            else if (radioButton70.Checked == true) A3 = 10000000;
            else if (radioButton69.Checked == true) A3 = 0.1;
            else if (radioButton68.Checked == true) A3=  0.01;
            sum = (A1 * 10 + A2) * A3;
            string b = sum.ToString() + ' ' + 'Ω';
            textBox2.Text = b;
        }

        //五色环阻值计算
        public void Calcu_resistance_value1()
        {
            double A1 = 0, A2 = 0, A3 = 0, A4 = 0, sum = 0;
            //第一环
            if (radioButton1.Checked == true)      A1 = 0;
            else if (radioButton2.Checked == true) A1 = 1;
            else if (radioButton3.Checked == true) A1 = 2;
            else if (radioButton4.Checked == true) A1 = 3;
            else if (radioButton5.Checked == true) A1 = 4;
            else if (radioButton6.Checked == true) A1 = 5;
            else if (radioButton7.Checked == true) A1 = 6;
            else if (radioButton8.Checked == true) A1 = 7;
            else if (radioButton9.Checked == true) A1 = 8;
            else if (radioButton10.Checked == true) A1 = 9;
            //第二环
            if (radioButton11.Checked == true)      A2 = 9;
            else if (radioButton12.Checked == true) A2 = 8;
            else if (radioButton13.Checked == true) A2 = 7;
            else if (radioButton14.Checked == true) A2 = 6;
            else if (radioButton15.Checked == true) A2 = 5;
            else if (radioButton16.Checked == true) A2 = 4;
            else if (radioButton17.Checked == true) A2 = 3;
            else if (radioButton18.Checked == true) A2 = 2;
            else if (radioButton19.Checked == true) A2 = 1;
            else if (radioButton20.Checked == true) A2 = 0;
            //第三环
            if (radioButton30.Checked == true) A3 = 0;
            else if (radioButton29.Checked == true) A3 = 1;
            else if (radioButton28.Checked == true) A3 = 2;
            else if (radioButton27.Checked == true) A3 = 3;
            else if (radioButton26.Checked == true) A3 = 4;
            else if (radioButton25.Checked == true) A3 = 5;
            else if (radioButton24.Checked == true) A3 = 6;
            else if (radioButton23.Checked == true) A3 = 7;
            else if (radioButton22.Checked == true) A3 = 8;
            else if (radioButton21.Checked == true) A3 = 9;
            //第四环
            if (radioButton40.Checked == true)      A4 = 1;
            else if (radioButton39.Checked == true) A4 = 10;
            else if (radioButton38.Checked == true) A4 = 100;
            else if (radioButton37.Checked == true) A4 = 1000;
            else if (radioButton36.Checked == true) A4 = 10000;
            else if (radioButton35.Checked == true) A4 = 100000;
            else if (radioButton34.Checked == true) A4 = 1000000;
            else if (radioButton33.Checked == true) A4 = 10000000;
            else if (radioButton22.Checked == true) A4 = 0.1;
            else if (radioButton31.Checked == true) A4 = 0.01;
            sum = (A1 * 100 + A2*10+A3) * A4;
            string b = sum.ToString() + ' '+'Ω';
            textBox4.Text = b;
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            Calcu_resistance_value();
            Calcu_resistance_value1();
        }
    }
}
